﻿<!DOCTYPE html>
<!--stop信息管理 bysongyf-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>
    <link href="/static/js/vue-treeselect/vue-treeselect.css" rel="stylesheet" />
    <script src="/static/js/vue-treeselect/vue-treeselect.js"></script>
    <style>
        .vue-treeselect__control {
            height: 100%;
            border: none;
            background: none;
        }

        .vue-treeselect__placeholder {
            top: -3px;
        }

        .vue-treeselect__single-value {
            top: -3px;
        }

        .el-input__suffix {
            z-index: 9;
        }

        #tcw0 .el-input__suffix {
            z-index: 10;
        }
    </style>
    <style>
        .el-dialog__body {
            height: 100% !important;
        }

        .el-dialog.is-fullscreen {
            overflow: hidden !important;
        }
    </style>
</head>

<body>
    
<div id="app" v-cloak>   
        <el-form label-position="right" ref="form" :inline="true" :model="formInline" class="demo-form-inline"
            style="margin-bottom: 15px;">
            <el-row>
                <el-col class="head-tool">
                    <div class="new_title fl"><strong><img src="/static/images/icon1.png" />STOP信息管理列表</strong></div>
                    <span>
                        <btn :text="col.btnSelect" imgsrc="/static/images/search.png" linetype="3" @click="onSubmit">
                        </btn>
                        <btn :text="col.btnAdd" linetype="3" @click="UserInput('tj')"></btn>
                        <btn-export-list url="/api/JG_STOPObserveMain/Export" :forminline="this.formInline" linetype="3"></btn-export-list>
                        <btn :text="col.btnDelete" linetype="4" @click="onDelete"></btn>
                    </span>
                </el-col>
            </el-row>
            <el-row class="popupW100">

                <list-factorys v-model="formInline.model.createFactory" @change="factoryChange"></list-factorys>
                <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    <!--{{STOPInformationManagement.department+mark.m}}-->
                                    {{"岗位:"}}
                                </template>
                                <treeselect v-model="formInline.model.department"
                                            :options="department"
                                            :flat="true"
                                            :show-count="true"
                                            slot="suffix"
                                            style="line-height: 28px;"
                                            placeholder="请选择" />
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini" style="z-index:100 !important;">
                                <template slot="prepend">
                                    {{STOPInformationManagement.situation+mark.m}}
                                </template>
                                <treeselect v-model="formInline.model.situation"
                                            :options="situation"
                                            :flat="true"
                                            slot="suffix"
                                            :show-count="true"
                                            style="line-height: 28px;"
                                            placeholder="请选择" />
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>


                <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{STOPInformationManagement.shifts+mark.m}}
                                </template>
                                <el-select @visible-change="visibleChange" v-model="formInline.model.shifts" slot="suffix"
                                           placeholder="请选择">

                                    <el-option v-for="item in shifts" :label="item.value" :value="item.key">
                                    </el-option>
                                </el-select>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input v-model="formInline.model.observation"
                                      :placeholder="STOPInformationManagement.observation" size="mini">
                                <template slot="prepend">
                                    {{STOPInformationManagement.observation+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{STOPInformationManagement.evaluation+mark.m}}
                                </template>
                                <el-select @visible-change="visibleChange" v-model="formInline.model.evaluationv" slot="suffix"
                                           :placeholder="STOPInformationManagement.evaluation">
                                    <el-option label="请选择" value=""></el-option>
                                    <el-option v-for="item in evaluation" :label="item.value" :value="item.key">
                                    </el-option>
                                </el-select>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{STOPInformationManagement.observaDateStart+mark.m}}
                                </template>
                                <el-date-picker v-model="formInline.model.ObservationtimeStart" type="date" slot="suffix"
                                                size="mini" placeholder="选择日期">
                                </el-date-picker>

                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>

                <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{STOPInformationManagement.observaDateEnd+mark.m}}
                                </template>
                                <el-date-picker v-model="formInline.model.ObservationtimeEnd" type="date" slot="suffix" size="mini" placeholder="选择日期">
                                </el-date-picker>

                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>


                <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{STOPInformationManagement.observePeople+mark.m}}
                                </template>
                                <tree-department-staff-single-jgstop slot="suffix" v-model="formInline.model.observePeople" style="line-height:28px;"></tree-department-staff-single-jgstop>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>








            </el-row>
        </el-form>
        <el-table ref="table" stripe :data="ListItem.tableData" :row-key="getRowKeys" :height="ListItem.tableHeight"
                  border @selection-change="handleSelectionChange" row-style="height:10px" style="width: 100%;">
            <el-table-column type="selection" style=" padding-top: 0px;  padding-bottom: 0px;  " align="center"
                             width="55" :reserve-selection="true">
            </el-table-column>
            <el-table-column type="index" :label="col.SequenceNumber" :index="indexMethod" width="50"
                             show-overflow-tooltip="true"></el-table-column>
            <el-table-column prop="departmentText" align="center" label="岗位">
            </el-table-column>
            <el-table-column prop="situationText" align="center" :label="STOPInformationManagement.situation">
            </el-table-column>
            <el-table-column prop="observePeopleText" align="center" :label="STOPInformationManagement.observePeople">
            </el-table-column>

            <el-table-column prop="shiftsText" align="center" :label="STOPInformationManagement.shifts">
            </el-table-column>
            <el-table-column prop="observation" align="center" :label="STOPInformationManagement.observation" min-width="140">
            </el-table-column>


            <el-table-column prop="observaDate" align="center" :label="STOPInformationManagement.observaDate" min-width="160">
            </el-table-column>
            <el-table-column prop="evaluationText" align="center" :label="STOPInformationManagement.evaluation" min-width="100">
            </el-table-column>
            <el-table-column width="53" prop="update" :label="col.btnUpdate" fixed="right">
                <template slot-scope="scope">
                    <button type="button" class="elst-bt-xg" @click=UserInput('xg',scope.row.id)>
                        <i class="el-icon-edit"></i>
                    </button>
                </template>
            </el-table-column>
        </el-table>
        <el-row type="flex" justify="end">
            <el-pagination ref="page" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="ListItem.currentPage" :page-sizes="ListItem.pagesizes" :page-size="ListItem.pagesize"
                :layout="ListItem.layout" :total="ListItem.total">
            </el-pagination>
        </el-row>
        <el-dialog title="STOP信息管理" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="80%" height="80%"
            top="10vh" fullscreen="true">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
    </div>
    <script type="text/javascript">
         Vue.component('tree-department-staff-single-jgstop', {
            props: ['value', 'multiple'],
            data: function () {
                return {
                    options: [],
                    valueConsistsOf: "LEAF_PRIORITY"
                }
            },
            methods: {
                input: function (v, instanceId) {
                    console.log(v);
                    this.$emit('input', v);
                },
                getData: function () {
                    var app = this;
                    myAjax("Get", null, "/api/JG_STOPObserveMain/GetTreeDepartmentStaff", null, function (response) {
                        var ajaxModel = response.data;
                        app.options = PersonMenuHelper(ajaxModel, guidEmpty);
                    }, false);
                }
            },
            mounted: function () {
                this.getData();
            },
            template: ' <treeselect :multiple="multiple"     :disable-branch-nodes="true"   :value-consists-of="valueConsistsOf"  :options="options"    v-model="value" @input="input"  />'

        })
        Vue.component('treeselect', VueTreeselect.Treeselect)
        app = new Vue({
            el: '#app',
            data: function () {
                return {
                    test: { title: 'abc', date: null },
                    ListItem: ListItem,
                    situation: [],
                    department: [],
                    evaluation: [],
                    shifts:[],
                    formInline: {
                        model: {
                            createFactory:null,
                            observePeople: null,    //观察人
                            observation: "",        //观察时间(h)
                            shifts: null,           //班次
                            situation: null,        //区域
                            department: null,       //部门
                            observaDate: "",        //观察日期
                            evaluationv: null,      //是否所有皆安全 
                            ObservationtimeStart: null, //开始日期
                            ObservationtimeEnd: null,   //结束日期
                        },
                        offset: 0,
                        limit: 10
                    }
                }
            }, created: function () {
                var currApp = this;
                window.onresize = function () {
                    currApp.ListItem.tableHeight = window.innerHeight -
                        currApp.$refs.table.$el.offsetTop - 60;
                    if (currApp.ListItem.tableHeight < 112) {
                        currApp.ListItem.tableHeight = 112;
                    }
                }
            },
            mounted: function () {
                this.test.date = new Date()
                var test1 = this.formInline;
                
                this.getDepartmentData();               //绑定部门
                this.shifts = getDicData('n51');        //绑定班次
                this.GetAreaList();                     //绑定区域
                this.evaluation = getDicData('是与否'); //绑定是否全部安全
                this.GetPageData(1);
                //列表高度自适应
                tablehigh(this);
            },
            updated: function () {
                var test1 = this.formInline;
            },
            beforeDestroy: function () {
                var test1 = this.formInline;
            },
            methods: {
                factoryChange: function () {
                    this.getDepartmentData();
                    this.GetAreaList();
                },
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                indexMethod: function (index) {
                    return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1;
                },
                handleNodeClick: function (data) {
                    console.log(data);
                },
                closeDialog: function () { closeDialog(this); },
                //删除方法
                onDelete: function () { onDelete(this, '/api/JG_STOPObserveMain/DeleteMuti'); },
                //列表选择触发
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //Dialog展示
                UserInput: function (val, id) { DialogShow(this, val, "STOPInformationManagementInput.html", id); },
                //获取分页数据
                GetPageData: function (currentIndex) {
                    
                    GetPageData(this, currentIndex, '/api/JG_STOPObserveMain/GetList')
                    //myAjax("post", this, '/api/JG_STOPObserveMain/Test', this.test, function (response) {

                    //}, false);
                },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },
                //初始化部门下拉树
                getDepartmentData: function () {
                    var mythis = this;
                    myAjax("post", this, '/api/SysDepartment/GetList', { model: { Name: '', Code: '', CreateFactory: mythis.formInline.model.createFactory }, offset: 0, limit: 999 }, function (response) {
                        mythis.department = menuHelperX(response.data.pageData, guidEmpty)
                    }, false);
                },
                //获得区域列表
                GetAreaList: function () {
                    var mythis = this;
                    myAjax("post", this, '/api/SysArea/GetList', { model: { Name: '', Code: '', SubFactory: mythis.formInline.model.createFactory }, offset: 0, limit: 999 }
                        , function (response) {
                            
                            mythis.situation = menuHelper(response.data.pageData, null);
                            
                        },
                        false);
                },
            }
        });
        //下拉树数据格式化
        function menuHelperX(list, pid) {
            var result = [];
            if (list.length <= 0)
                return list;
            list.forEach(function (v, i) {
                var temp = {};
                for (var key in v) {
                    temp[key] = v[key];
                }
                temp.label = v.name;
                temp.parentId = temp.parentId ? temp.parentId : guidEmpty;
                var obj;
                if (temp.parentId == pid) {
                    obj = temp;
                    var nextObj = menuHelperX(list, temp.id);
                    if (nextObj.length > 0) {
                        obj.children = nextObj;
                    }
                }
                if (obj)
                    result.push(obj)
            })
            return result;
        }

        //下拉树数据格式化
        function menuHelper(list, pid) {

            var result = [];
            if (list.length <= 0)
                return list;
            list.forEach(function (v, i) {
                var temp = {};
                for (var key in v) {
                    temp[key] = v[key];
                }
                temp.label = v.name;
                //temp.parentId = temp.parentId ? temp.parentId : guidEmpty;
                var obj;
                if (temp.parentId == pid) {
                    obj = temp;
                    var nextObj = menuHelper(list, temp.id);
                    if (nextObj.length > 0) {
                        obj.children = nextObj;
                    }
                }
                if (obj)
                    result.push(obj)
            })
            return result;
        }

    Vue.component('list-factorys-all-jgstop', {
    props: ['value'],
    data: function () {
        return {
            data: [],
            model: this.value
        }
    },
    methods: {
        getdData: function () {
            var url = "/api/WebPageInitial/FactoryListAll";
            var app = this;
            myAjax("get", this, url, null, function (response) {
                app.data = response.data;

            }, false);

            //if (this.data && this.data.length > 0)
                //this.model = this.data[0].key;
        },
    },
    mounted: function () {
        this.getdData();
    },
    watch: {
        // 如果 `question` 发生改变，这个函数就会运行
        model: function (newQuestion, oldQuestion) {
            this.$emit('input', newQuestion);
            this.$emit('change', newQuestion);
        },
        value: function (newQuestion, oldQuestion) {
            this.model = newQuestion;
        }
    },
    template: '<el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6"><div class= "elst-select-mini" ><el-form-item><el-input size="mini"><template slot="prepend">{{"工厂"+mark.m}}</template>'
        + '<el-select @visible-change="visibleChange"  v-model="model"  slot="suffix" placeholder="请选择">'
       
        + '<el-option v-for="item in data" :label="item.value" :value="item.key"></el-option>'
        + '</el-select>'
        + '</el-input></el-form-item></div ></el-col>'
})
    </script>
</body>

</html>